package serach;

public class BM17 {
    public int search (int[] nums, int target) {
        if(nums.length==0) return -1;
        int start =0;
        int end =nums.length-1;
        while (start<end)
        {
            int mid = (start+end)/2;
            if(nums[mid]==target)
            {
                return mid;
            }
            if(nums[mid]<target)
            {
                start = mid+1;
            }
            if(nums[mid]>target)
            {
                end = mid-1;
            }
        }
        return -1;
        // write code here
    }
}
